//
//  NLBaseNavController.swift
//  sinaWeibo7110
//
//  Created by 安静清晨 on 2017/1/5.
//  Copyright © 2017年 walk-in-minds. All rights reserved.
//

import UIKit

class NLBaseNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
       
        //统一设置返回按钮的格式.
        //不能直接设置backBarButtonItem, 因为他是私有的
        //MARK:flag
        let count = self.childViewControllers.count
        
        //根视图控制器设置为没有返回按钮
        if count > 0{
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: nil, action: #selector(goBack))
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: true)
        
    }
    
    
    func goBack (){
        
        self.popViewController(animated: true)
        
        
    }
    

}
